/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package sim;

import java.awt.Color;
import java.awt.Graphics2D;
import java.awt.MultipleGradientPaint.CycleMethod;
import java.awt.Point;
import java.awt.RadialGradientPaint;
import java.awt.geom.Ellipse2D;
import java.awt.geom.Point2D;

/**
 *
 * @author Administrator
 */
public class Face extends Ellipse2D.Double {

    private int color;
    private Point offset = new Point();
    private Graphics2D g2;
    private Color[] colors = {Color.WHITE, Color.BLUE, Color.ORANGE};

    public Face(Ellipse2D.Double circle) {

        super(circle.x, circle.y, circle.width, circle.height);

    }

    public Face(Ellipse2D.Double circle, int int_color) {
        super(circle.x, circle.y, circle.width, circle.height);

        color = int_color;
        setColor(color);

    }

    public void setColor(int int_color) {

        color = int_color;
        if (color == 1) {
            colors[0] = Color.WHITE;
            colors[1] = Color.WHITE;
            colors[2] = Color.ORANGE;
        } else if (color == 2) {
            colors[0] = Color.WHITE;
            colors[1] = Color.RED;
            colors[2] = Color.ORANGE;
        } else if (color == 3) {
            colors[0] = Color.WHITE;
            colors[1] = Color.BLUE;
            colors[2] = Color.ORANGE;
        } else {
            colors[0] = Color.WHITE;
            colors[1] = Color.BLACK;
            colors[2] = Color.ORANGE;
        }
    //repaint();

    }

    public int getColor() {

        return color;

    }

    public void setOffset(Point p) {

        offset.x = p.x - (int) x;
        offset.y = p.y - (int) y;

    }

    public void setLocation(Point p) {

        x = p.x - offset.x;
        y = p.y - offset.y;

    }

    public void paint(Graphics2D g) {

        g2 = g;
        Point2D.Double noseCenter = new Point2D.Double(getCenterX(),
                getCenterY());
        float[] floats = {0.1f, 0.3f, 0.6f};
        //Color[] colors = {Color.WHITE, Color.YELLOW, Color.ORANGE};
        //Color[] colors = {Color.WHITE, Color.BLUE, Color.ORANGE};
        RadialGradientPaint paint = getPaint(this, noseCenter, floats, colors);
        g2.setPaint(paint);
        g2.fill(this);
        g2.setColor(Color.BLACK);
        g2.draw(this);

    }

    private RadialGradientPaint getPaint(Ellipse2D.Double circle,
            Point2D.Double focus, float[] floats, Color[] colors) {

        Point2D.Double center = new Point2D.Double(circle.getCenterX(),
                circle.getCenterY());
        return new RadialGradientPaint(center, (float) circle.width, focus,
                floats, colors, CycleMethod.NO_CYCLE);

    }
}
